package com.sjd.quartz.task;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.sjd.farm.service.WxFarmOrderService;
import com.sjd.mall.service.order.WxOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 订单取消任务
 * <p>
 * 2h未支付的订单自动取消
 * 0 0/1 * * * ?
 *
 * @author seer
 * @version 1.0
 * @date 2022/1/19 10:09
 */
@Component("orderCancelTask")
@Slf4j
public class OrderCancelTask {

    @Autowired
    private WxOrderService orderService;

    @Autowired
    private WxFarmOrderService farmOrderService;

    public void exec0() {
        log.info("订单自动取消定时任务执行 {}", LocalDateTimeUtil.formatNormal(LocalDateTime.now()));
        orderService.cancelQuartz();
        farmOrderService.cancelQuartz();
    }
}